package view
{
    import flash.display.*;
    import flash.geom.*;

    public class Bullet extends Sprite
    {
        public var vx:Number;
        public var vy:Number;

        private var _radius:Number;
        private var _color:uint;

        public function Bullet(vx:Number, vy:Number, radius:Number=3, color:uint=0x3080FF)
        {
            this.vx = vx;
            this.vy = vy;
            _radius = radius;
            _color = color;
        }

        public function display():void
        {
            graphics.clear();
            var matrix:Matrix = new Matrix();
            matrix.createGradientBox(2*_radius, 2*_radius, 0, -_radius, -_radius);
            graphics.beginGradientFill(GradientType.RADIAL,
                                       [0xFFFFFF, _color],
                                       [1, 0.5], [63, 255], matrix);
            graphics.drawCircle(0, 0, _radius);
            graphics.endFill();
        }

        public function update(t:Number):void
        {
            x += t * vx;
            y += t * vy;
        }
    }
}
